home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_text.zip / PUT_COLO.ASM < prev    next >
Assembly Source File  |  1987-06-16  |  2KB  |  56 lines

  1. ;--------------------------------------------------------------------------;
  2. ; Put_color_str(string, attribute) - String should be a pointer to the     ;
  3. ; string to be printed and attribute should be the attribute byte.  If     ;
  4. ; column 79 is reached, the cursor is moved to the next line, if possible .;
  5. ; Printing stops if row 24, column 79 is reached                           ;
  6. ;--------------------------------------------------------------------------;
  7.  
  8.         ASSUME  CS:_TEXT
  9. _TEXT   SEGMENT BYTE    PUBLIC  'CODE'
  10.         PUBLIC  _PUT_COLOR_STR
  11. _PUT_COLOR_STR     PROC    NEAR
  12.         PUSH    BP
  13.         MOV     BP,SP
  14.         PUSH    DI
  15.         PUSH    SI
  16.         PUSH    DS
  17.         PUSH    ES
  18.  
  19.         MOV     SI,[BP+4]               ;Pointer to string
  20.         MOV     BL,[BP+6]               ;Attribute character
  21.  
  22. STRING_LOOP:
  23.         LODSB                           ;Load a character into AL
  24.         CMP     AL,0                    ;Check for end of string Null char.
  25.         JE      END_OF_STRING
  26. CHAR_PRINT:
  27.         MOV     AH,9                    ;Service 9, print character
  28.         MOV     CX,1                    ;Print character 1 time
  29.         MOV     BH,0                    ;Display page 0
  30.         INT     10h
  31.         MOV     AH,3                    ;Service 3, get cursor position
  32.         INT     10h
  33.         INC     DL                      ;Increment column
  34.         CMP     DL,79                   ;Check for end of row
  35.         JBE     SAME_ROW                ;Not end of row, print on same row
  36.         CMP     DH,24                   ;Check for row 24
  37.         JE      END_OF_STRING           ;If row 24, stop printing
  38.         XOR     DL,DL                   ;Move to column 0
  39.         INC     DH                      ;Move to nex row
  40. SAME_ROW:
  41.         MOV     AH,2                    ;Service 2, move cursor
  42.         INT     10h
  43.         JMP     STRING_LOOP             ;Next character
  44. END_OF_STRING:
  45.         POP     ES
  46.         POP     DS
  47.         POP     SI
  48.         POP     DI
  49.         POP     BP
  50.         RET
  51. _PUT_COLOR_STR ENDP
  52.  
  53. _TEXT   ENDS
  54.         END
  55.  
  56.